package com.laikan.reader.core.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.laikan.reader.core.LaikanBaseAdapter;
import com.laikan.reader.R;
import com.laikan.reader.core.bean.FansTwo;

import java.util.ArrayList;

public class FansAdapter extends LaikanBaseAdapter<FansTwo> {

    ViewHolder holder = null;

    public FansAdapter(Context context,ArrayList<FansTwo> moreList) {
        super(context,moreList);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {

        //		if (convertView == null) {
        holder = new ViewHolder();
        convertView = View.inflate(mContext, R.layout.lk_fans_item, null);
        convertView.setTag(holder);
        holder.book_img = (ImageView)convertView.findViewById(R.id.fan_book_image);

        holder.followerName = (TextView)convertView.findViewById(R.id.followerName);

        holder.follower_level = (TextView)convertView.findViewById(R.id.follower_level);

        holder.follow = (TextView)convertView.findViewById(R.id.follow);

        holder.rank_num = (TextView)convertView.findViewById(R.id.rank_num);
        //		} else {
        //			holder = (ViewHolder) convertView.getTag();
        //		}

        switch (position) {
            case 0:
                holder.rank_num.setText("1");
                holder.rank_num.setBackgroundResource(R.drawable.rank_bg_red);
                break;
            case 1:
                holder.rank_num.setText("2");
                holder.rank_num.setBackgroundResource(R.drawable.rank_bg_org);
                break;
            case 2:
                holder.rank_num.setText("3");
                holder.rank_num.setBackgroundResource(R.drawable.rank_bg_yellow);
                break;

            default:
                holder.rank_num.setText(position + 1 + "");
                holder.rank_num.setBackgroundResource(R.drawable.rank_bg_gray);
                if (position > 100) {
                    holder.rank_num.setTextSize(12);
                }else {
                    holder.rank_num.setTextSize(16);
                }
                break;
        }

        holder.book_img.setImageURI(Uri.parse(datas.get(position).getFollowerIcon()));
        holder.followerName.setText(datas.get(position).getFollowerName());
        holder.follower_level.setText(datas.get(position).getLevel());
        holder.follow.setText(datas.get(position).getFollow());
        return convertView;
    }

    private class ViewHolder {

        public ImageView book_img;
        public TextView followerName, follower_level, follow, rank_num;
    }

}
